package Testdmo3;

import java.util.Random;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:周次煜
 * Date: 2024-03-20
 * Time：16:14
 */


public class J3_20 {


    void func1(int N){
        int count = 0;
        for (int i = 0; i < N ; i++) {
            for (int j = 0; j < N ; j++) {
                count++;
            }
        }

        for (int k = 0; k < 2 * N ; k++) {
            count++;
        }
        int M = 10;
        while ((M--) > 0) {
            count++;
        }
        System.out.println(count);
    }



    public static  void  Meau(){
        System.out.println("****** 有以下三种难度 *********");
        System.out.println("**** 1，高难度:猜五次 *********");
        System.out.println("**** 2.中难度: 猜十次 *********");
        System.out.println("**** 3.低难度:猜十五次 ********");
        System.out.println("**** 0. 退出  游戏    ********");
    }
    public static void game(int count){
        Scanner in = new Scanner(System.in);
        Random r=new Random();
        int num= r.nextInt(100);
        System.out.println("数字范围为：1~100");
        while (count != 0){
            System.out.print("请输入你要猜的数字：");
            int  guess=in.nextInt();
            if (guess>num){
                System.out.println("猜大了！");
            }else if (guess<num){
                System.out.println("擦小了！");
            }else {
                System.out.println("恭喜你，猜对了！");
                break;
            }
            count --;
            System.out.printf("你还能猜 %d 次！\n",count);
        }
        if (count==0){
            System.out.println("很遗憾！你未能猜对，游戏结束...");

        }
    }
    //        猜数字游戏
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);

        int choose=0;
        do {
            Meau();
            System.out.print("请选择你需要难度合法的数字：");
            choose=in.nextInt();
            switch (choose){
                case 0:
                    System.out.println("游戏正在退出中...");
                    break;
                case 1:
                    System.out.println("你选择的是高难度：五次");
                    game(5);
                    break;
                case 2:
                    System.out.println("你选择的是中难度：十次");
                    game(10);
                    break;
                case 3:
                    System.out.println("你选择的是低难度：十五次");
                    game(15);
                    break;
                default:
                    System.out.println("输入不合法，请重新输入");
                    break;
            }
        }while (choose != 0);

    }
}
